var express = require('express');
var path = require('path');
var bodyParser=require('body-parser');

var app = express();

app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

app.get('/',function(req,res){
    res.sendFile(__dirname+'/public/index.html');
});

var apiRouter=express.Router();

// apiRouter.post('/login',function(req,res){
//     console.log(req.body);
//     res.send({"role":"admin"});
// });

var login=require('./routes/login');
var queryAction=require('./routes/query');
//登陆
apiRouter.post('/education/login.action',login.login);
//查询学生信息
apiRouter.post('/education/administrator/queryStuInfo.action',queryAction.queryStuInfo);

// app.use('/education',apiRouter);
app.use(apiRouter);

app.use(function(req, res, next) {
    res.status(404).send('404 error');
});
app.use(function(err, req, res, next) {
    console.error(err.stack);
    res.status(500).send('500 Error');
});



module.exports = app;
